package priv.dajie.tzzq.common;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @ClassName ApplicationContextUnit
 * @Description
 * @Author dajie
 * @Date 2019/10/24 12:25 上午
 * @Version V1.0
 **/
public class ApplicationContextUnit {

    private static ClassPathXmlApplicationContext instance;

    public static synchronized ApplicationContext getInstance(){
        if (instance == null){
            create();
        }
        return instance;
    }

    private static void create(){
        synchronized (ApplicationContextUnit.class){
            if (instance == null){
                instance = new ClassPathXmlApplicationContext("config/applicationContext.xml");
                instance.registerShutdownHook();
                instance.start();
            }
        }
    }


}
